package cn.ibizlab.modeling.groovy

import groovy.transform.CompileStatic
import net.ibizsys.central.dataentity.IDataEntityRuntime
import net.ibizsys.central.dataentity.action.DEActionRuntimeBase
import net.ibizsys.central.util.IEntityDTO
import org.springframework.util.Assert

@CompileStatic
class UninstallSysDEActionRuntime extends DEActionRuntimeBase{

    public GitRegisterDEActionRuntime() {
    }

    @Override
    protected Object onExecute(IEntityDTO iEntityDTO) throws Throwable {
        String psdevslnsysid = iEntityDTO.getString("psdevslnsysid","")
        Assert.notNull(psdevslnsysid,"未传入系统标识")
        IDataEntityRuntime wsDataEntityRuntime = this.getSystemRuntime().getDataEntityRuntime("DevCenter.PSDCWORKSPACE")
        //查找本方案内空闲生产线
        IEntityDTO ws = wsDataEntityRuntime.filter().eq("psdevslnsysid",psdevslnsysid).selectOne(true)

        if(ws) {

            wsDataEntityRuntime.executeAction("uninstallSys", null, [ws] as Object[])
        }
        else {
            throw new Exception("未找到生产线，卸载失败");
        }
        this.getDataEntityRuntime().get(psdevslnsysid).copyTo(iEntityDTO)
        return iEntityDTO
    }


}